home *** CD-ROM | disk | FTP | other *** search
- /*RX
- * AREXX Name:Start_TeX.ged Version:1.41 Date:27-Jul-91
- *
- This AREXX script saves and compiles the current GED view. The only
- (optional) argument is the format to be used. A '?' formatname will
- interactively ask for the format to use.
- *
- A command is send to the TeX server to compile the file. Hence a
- return value of 0 does not mean that the file compiled well, but only
- that the command was sent to the server and replied to.
- *
- AUTHOR:
- * J\"org H\"ohle, March 91
- *
- * small modifications for GoldED by Markus Aretz
- BUGS:
- virtex doesn't like filenames with blanks (and ARexx parses them
- hardly too), so avoid them in file, directory *and* device names.
- *
- Does not like names relative to the local root, like ":foo/bar"
- *
- FILES:
- ENV:TEXFORMAT: default format used
- REXX:namestruc
- *
- */
-
- OPTIONS RESULTS /* enable return codes */
-
- if (LEFT(ADDRESS(), 6) ~= "GOLDED") then /* not started by GoldEd ? */
- address 'GOLDED.1'
-
- 'LOCK CURRENT' /* lock GUI, gain access */
- OPTIONS FAILAT 6 /* ignore warnings */
- SIGNAL ON SYNTAX /* ensure clean exit */
-
- /* OPTIONS FAILAT 3 */
-
- /**
- IF ~SHOW('L','rexxsupport.library') THEN
- IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
- 'REQUEST BODY "Can't open ''rexxsupport.library'!"'
- EXIT 20
- END
- **/
-
- portname = 'Start_TeX'
- script = 'TeX-server.ged' /* no path required, message only */
-
- IF "" = GetClip("TEX QUERY") THEN askformat = 0
- ELSE askformat = 1 /* ask interactively for format name */
-
- PARSE ARG format .
- IF "?" = format THEN DO
- askformat= 1
- format = ""
- END
- ELSE IF '&' = LEFT(format,1) THEN
- format = SUBSTR(format,2)
-
- 'QUERY FILE VAR LOADEDFILE'
- 'QUERY PATH VAR LOADEDDIR'
- IF RIGHT(loadeddir,1)~='/' & RIGHT(loadeddir,1)~=':' THEN
- loadeddir = loadeddir||'/'
-
- 'QUERY DOC VAR FULLNAME'
-
- /* fullname = loadeddir||loadedfile */
-
- PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
-
- IF "TEX" ~= UPPER(RIGHT(loadedfile,3)) THEN DO
- 'REQUEST BODY "Sorry, filename must have an extension and end in `tex''."'
- 'UNLOCK'
- EXIT 5
- END
-
- IF 0 = ivol THEN DO
- direc = PRAGMA('D')
- IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
- fullname = direc||fullname
- DROP direc
- END
- DROP ivol idirs ibase
-
- /* Save only if file has been modified */
- 'QUERY MODIFY VAR RESULT'
- IF RESULT = 'TRUE' THEN DO
- 'REQUEST BODY "File has been modified|Save it first?" BUTTON "_Yes|_No"'
- IF RESULT='1' THEN 'SAVE ALL'
- END
-
- IF (SHOW('P', portname)) THEN DO
- /* set the default format, modify it to suit your needs */
- envformat = mygetenv("TEXFORMAT")
- IF "" == format THEN DO
- format = envformat
- IF askformat | "" = envformat THEN DO
- IF "" = format THEN format = 'plain'
-
- 'REQUEST STRING VAR NFORMAT DEFAULT format BODY "Which format to use ?"'
- /* "RESULT" if cancelled */
- IF "RESULT" ~= NFORMAT THEN format = NFORMAT
-
- END /* askformat */
- END /* format */
-
- /* If the server is already busy with some compilation, this will
- wait till compilation finishes, this may take a long time */
- /* no unlocking (like in MG) available */
-
- if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
-
- 'UNLOCK'
- ADDRESS VALUE portname
- 'compile' format fullname
- EXIT
- END
- ELSE DO
- /* The TeX server must be started first */
- 'REQUEST BODY "The TeX server '''script''' is not running !"'
- 'UNLOCK'
- EXIT 5
- END
-
- SYNTAX:
-
- SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
- 'UNLOCK'
- EXIT
-
- mygetenv: procedure /* when will ARexx supply GetEnv/SetEnv ? */
- PARSE ARG name
-
- IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
- gives = readln(TEMPFILE)
- CALL close TEMPFILE
- END
- ELSE gives = ""
-
- RETURN gives
-
- mysetenv: procedure
- PARSE ARG name,content
-
- ADDRESS COMMAND "SetEnv" name content
-
-
- RETURN
-